lane :release_pod do |options|

  target_version = options[:t]
 
  target_project = options[:p]

  target_repo  = options[:r]

  update_message  = options[:m]
  
  if_pod  = options[:i]

  spec_path = "#{target_project}.podspec"
  
  # git pull
  git_pull(only_tags: true)

  # 确认是 master 分支
  ensure_git_branch
  # 确认是 main 分支
  # ensure_git_branch( branch: 'main' )
  
  if  if_pod
  # 修改 spec 为即将发布的版本
  version_bump_podspec(path: spec_path, version_number: target_version)
  end
  
  # 将本地代码加入本地仓库里
  git_add(path: '.')
  
  # 提交修改到本地仓库
  git_commit(path: '.', message: update_message)
  
  if  if_pod
  # 在push之前, 查看spec是否配置有问题，验证 spec 文件
  pod_lib_lint(verbose: true, allow_warnings: true)
  # 私有仓需要添加验证仓Sources
  # pod_lib_lint(verbose: true, allow_warnings: true, sources: 'https://github.com/CocoaPods/Specs.git,https://codeup.aliyun.com/6279dbf7487c500c27f5744e/group1/ModuleSpace.git')
  end
  
  # 推送master分支的代码到名称为origin的远程仓库
  push_to_git_remote
  
  # 检查对于 tag 是否已经存在
  if git_tag_exists(tag: target_version)
      # 删除对应 tag
      remove_git_tag(tag: target_version)
  end
  
  # 添加 tag
  add_git_tag(tag: target_version)
  
  # 提交 tag
  push_git_tags
  
  if  if_pod
  # # pod trunk push 'spec_path'
  # pod_push(path: spec_path, allow_warnings: true,verbose: true)
    # 检查是否传了 repo 参数
    if target_repo
    # pod repo push 'target_repo' 'spec_path'

      pod_push(path: spec_path, repo: target_repo, allow_warnings: true, verbose: true)

    else
    # pod trunk push 'spec_path'

      pod_push(path: spec_path, allow_warnings: true, verbose: true)

    end
  end
end